﻿<%@ Page Language="C#" MasterPageFile="../Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<%@ Import Namespace="Microsoft.Web.Mvc"%>
<asp:Content ID="indexHead" ContentPlaceHolderID="head" runat="server">
    <title>Đơn Hàng Thuê Admin</title>
</asp:Content>

<asp:Content ID="css_js" ContentPlaceHolderID="js_css" runat="server">
</asp:Content>

<asp:Content ID="head_content" ContentPlaceHolderID="head_content" runat="server">
    <% Html.RenderAction("index","head"); %>
</asp:Content>

<asp:Content ID="indexContentRight" ContentPlaceHolderID="main_content" runat="server">
 <div class="breadcrumb">
    <a href="/admin/home">Home</a>:: <a href="/admin/billrent">Danh sách đơn hàng Thuê</a>
</div>
    
  <% if (Convert.ToInt32(ViewData["success"]) == 1)
     {%><div class="success">Thao tác thành công</div><%}else if(Convert.ToInt32(ViewData["success"]) == 2) {%>
        <div class="warning">Có lỗi trong quá trình thao tác</div>
  <% } %>
<div class="box">
<link rel="stylesheet" type="text/css" media="all" href="/admin/content/jsDatePick_ltr.min.css" />
<script type="text/javascript" src="/admin/Scripts/jquery/ui/ui.datepicker.js"></script>
<script type="text/javascript"><!--
$(document).ready(function() {
	$('#filter_date').datepicker({dateFormat: 'dd-mm-yy'});
});
//--></script>
  <div class="left"></div>
  <div class="right"></div>
  <div class="heading">
    <h1 style="background-image: url('image/order.png');">Danh sách đơn hàng</h1>
    <div class="buttons"><a onclick="DeleteBillMany();" class="button"><span>Xoá</span></a></div>
  </div>
  <div class="content">
    <form action="#" method="post" enctype="multipart/form-data" id="form_bill" name ="form_bill">
      <table class="list">
        <thead>
          <tr>
            <td style="text-align: center;" width="1"><input onclick="$('input[name*=\'selected\']').attr('checked', this.checked);" type="checkbox"></td>
            <td class="left">
				<a href="#">Mã đơn hàng</a>
			</td>
            <td class="left">              
				<a href="#" >Tên khách hàng</a>
            </td>
            <td class="left">              
				<a href="#">Trạng thái</a>
            </td>
            <td class="left">              
				<a href="#">Ngày lập</a>
            </td>			
            <td class="left">              
				<a href="#">Tổng tiền</a>
            </td>
            <td class="right"></td>
          </tr>
        </thead>
        <tbody>
          <tr class="filter">
            <td></td>
            <td><input name="filter_id" type="text" maxlength = "30" value = "<% = ViewData["filter_id"] %>"></td>
            <td><input name="filter_name" type="text" maxlength = "40" value = "<% = ViewData["filter_name"] %>"></td>
            <td>			
			<select name="filter_status">
			    <option value="">Chọn tình trạng</option>
                <option value="1" <% if((ViewData["filter_status"]!=null)&&(ViewData["filter_status"].ToString()=="1")){ %>selected = "selected"<% } %>>Mới</option>
                <option value="2" <% if((ViewData["filter_status"]!=null)&&(ViewData["filter_status"].ToString()=="2")){ %>selected = "selected"<% } %>>Đang xử lý</option>
				<option value="3" <% if((ViewData["filter_status"]!=null)&&(ViewData["filter_status"].ToString()=="3")){ %>selected = "selected"<% } %>>Hoàn Thành</option>
				<option value="4" <% if((ViewData["filter_status"]!=null)&&(ViewData["filter_status"].ToString()=="4")){ %>selected = "selected"<% } %>>Huỷ</option>
            </select>
			</td>
            <td><input name="filter_date"  id="filter_date" type="textbox" /></td>
            <td ><input name="filter_total" type="text" onkeydown = "validate(event)" maxlength="20" value = "<% = ViewData["filter_total"] %>" /></td>
            <td align="right"><a class="button" style="text-decoration:none;" onclick = "filterkeyword();"><span>Lọc</span></a></td>
          </tr>
            <% string [][] AllBill = (string[][])ViewData["AllBill"] ;%>
            <% if ((AllBill != null) && (AllBill.Length != 0)&&(AllBill[0]!=null))
               {  %>
            <% foreach (string[] Bill in AllBill)
               {
                   if (Bill == null) break;%>
		  <tr>
            <td style="text-align: center;">              
				<input name="selected[]" value="<% = Bill[0] %>" type="checkbox"/>
             </td>
            <td class="left"><% = Bill[1]  %></td>
            <td class="left"><% = Bill[2] %></td>
            <td class="left"><% switch (Convert.ToInt32(Bill[3]).ToString())
                                { %>
             <% case "1":
                                        { %> Mới <% break;
                                        } %>
             <% case "2":
                                        { %> Đang Xử Lý <% break;
                                        } %>
             <% case "3":
                                        { %> Hoàn Thành <% break;
                                        } %>
             <% case "4":
                                        { %> Hủy <% break;
                                        } %>
             <%} %>
            </td>
            <td class="left"><% = Bill[4] %></td>
            <td class="left"><% = Bill[5] %> VNĐ</td>
            <td class="right">[ <a href="/admin/billrentdetail/index?bid=<% = Bill[0] %>">Sửa</a> ] [ <a href="javascript:;" onclick = "DeleteBill(<% = Bill[0] %>)">Xoá</a> ]</td>
          </tr>
			<% }
               } %>
             <tr style='background-color:white;'>
               <td colspan='11' height='40' align='center'>
                  <div class='pagination' style='width:98%;'>
                   <% = ViewData["pagination"] %>
                   </div> 
                </td> 
            </tr> 
         </tbody>
      </table>
    </form>
    
  </div>
</div>

<script type="text/javascript"><!--
$('#form input').keydown(function(e) {
	if (e.keyCode == 13) {
		filter();
	}
});
function validate(evt) {
  var theEvent = evt || window.event;
    evt = (evt) ? evt : ((event) ? event : null);
   if(evt){
        if((evt.keyCode < 48 || evt.keyCode > 57) && evt.keyCode != 8 && evt.keyCode!=46)
        {
            theEvent.returnValue = false;
            if(theEvent.preventDefault) theEvent.preventDefault();
        }
  }
}
//--></script>
<script type ="text/javascript">
    function filterkeyword()
    {
       var form = document.getElementById('form_bill');
       form.action = "/admin/billrent/";
       form.submit();
    }
    
    function DeleteBillMany(){
        Listchb = document.getElementsByName("selected[]");
        var i=0;
        var count=0;
        for (i = 0;i<Listchb.length;i++)
        {
            if(Listchb[i].checked == true)
            {
                count++;
                break;
            }
        }
        if(count>0)
        {
            if(window.confirm("Bạn có chắc muốn xóa các đơn hàng hay không"))
            {
                var form = document.getElementById('form_bill');
                form.action = "/admin/billrent/deletemany";
                form.submit();
            }
        }
        else
        {
            alert("Bạn phải chọn ít nhất 1 đơn hàng");
        }
    }
    function DeleteBill(id){
        if(window.confirm("Bạn có chắc muốn xóa  đơn hàng hay không"))
        {
           window.location.href = "/admin/billrent/delete?bid="+id;
        }
    }
</script> 
</asp:Content>
